package com.kehao.leetcode.basic.math;

import org.junit.Test;

public class PrimeNumberSolution {

    public int countPrimes(int n) {
        boolean[] notPrime = new boolean[n];
        int result = 0;
        for (int i = 2; i < n; i++) {
            if(notPrime[i]){
                continue;
            }
            result++;
            for (int j = i*2; j < n; j+=i) {
                notPrime[j] = true;
            }
        }
        return result;
    }



    @Test
    public void test01(){
        System.out.println(countPrimes(10));
    }
}
